package com.igeek.boot.exception;

import com.igeek.boot.entity.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @package com.igeek.boot.exception
 * @Description 设置全局异常处理器
 * @Author LittlePunk [296526219@qq.ccom]
 * @Version 2022.1
 * @Date 2023/12/7 20:15
 */
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result exceptionHandler(Exception e){
        log.error("异常：{}",e.getMessage());
        return new Result(411,"exception异常");
    }

    @ExceptionHandler(noLoginException.class)
    public Result noLoginHandler(Exception e){
        log.error("异常：{}",e.getMessage());
        return new Result(491,"exception异常");
    }
}
